package audio;

import java.io.IOException;

import javax.media.Manager;
import javax.media.NoPlayerException;
import javax.media.Player;
import javax.media.protocol.DataSource;

import jmapps.util.StateHelper;

public class Recepcao {
	
	private DataSource som ;
	private Player tocador;

	public Recepcao(DataSource fonte) throws NoPlayerException, IOException {
		this.som = fonte;
		this.tocador = Manager.createPlayer(som);
	}

	public DataSource getSom() {
		return som;
	}

	public void setSom(DataSource som) {
		this.som = som;
	}

	public Player getTocador() {
		return tocador;
	}

	public void setTocador(Player tocador) {
		this.tocador = tocador;
	}
	
	public void receber(){
		StateHelper sh = new StateHelper(this.tocador);
		//configura o player para realize
		if(!sh.realize(100000)){
			System.out.println("estourou o tempo.");
		}
		this.tocador.start();		
	}
}
